/** 
 * @memo 创建Ext-FckEditer方法 
 * @author lic
 * @sample 粘贴用
 
		 
 * @detail 注释
 * @method
		 
 */

Ext.form.CKEditor = function(config){
    this.config = config;
    Ext.form.CKEditor.superclass.constructor.call(this, config);
};

Ext.extend(Ext.form.CKEditor, Ext.form.TextArea,  {
    onRender : function(ct, position){
        if(!this.el){
            this.defaultAutoCreate = {
                tag: "textarea",
                autocomplete: "off"
            };
        }
        Ext.form.TextArea.superclass.onRender.call(this, ct, position);
        //添加上传配置
        this.config.CKConfig.filebrowserImageBrowseUrl = getRootPath()+'/sample/imageView.bi?decorate=no';
        this.config.CKConfig.filebrowserImageUploadUrl = getRootPath()+'/fck/fck.report?method=uploadFiles&Type=Image';
        this.config.CKConfig.filebrowserFlashBrowseUrl = getRootPath()+'/fck/fck.report?method=uploadFiles&Type=Flash';
        this.config.CKConfig.filebrowserFlashUploadUrl = getRootPath()+'/fck/fck.report?method=uploadFiles&Type=Flash';
        CKEDITOR.replace(this.id, this.config.CKConfig);
    },
    
    setValue : function(value){
        Ext.form.TextArea.superclass.setValue.apply(this,[value]);
        CKEDITOR.instances[this.id].setData( value );
    },

    getValue : function(){
        
        CKEDITOR.instances[this.id].updateElement();
       
        return Ext.form.TextArea.superclass.getValue.apply(this);
    },

    getRawValue : function(){
        CKEDITOR.instances[this.id].updateElement();    
        return Ext.form.TextArea.superclass.getRawValue.apply(this);
    }
});
Ext.reg('ckeditor', Ext.form.CKEditor);